import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Row, Col,Input,Select,Button, Table,Space } from 'antd';
import "./GroupPurchase.css"
import axios from 'axios'

const { Option } = Select;


const columns = [
    {
      title: '团购编号',
      dataIndex: 'gro_sysnum',
      key: 'gro_sysnum',
    },
    {
      title: '团购商品',
      dataIndex: 'pro_name',
      key: 'pro_name',
    },
    {
      title: '团长',
      dataIndex: 'user_username',
      key: 'user_username',
    },
    {
      title: '团购人数',
      key: 'gro_grocount',
      dataIndex: 'gro_grocount',
    },
    {
      title: '还差人数',
      key: 'gro_lack',
      dataIndex: 'gro_lack',
    },
    {
      title: '拼团时间',
      key: 'gro_starttime',
      dataIndex: 'gro_starttime',
    },
    {
      title: '拼团状态',
      key: 'jia_ge',
      dataIndex: 'jia_ge',
    },
    {
      title: '操作状态',
      key: 'gro_state',
      dataIndex: 'gro_state',
    },
    {
      title: '操作',
      key: 'action',
      render: (text, record) => (
        <Space size="middle">
          <Button type="default">查看</Button>
        </Space>
      ),
    },
  ];
function handleChange(value) {
    // console.log(`selected ${value}`);
  }
class GroupPurchase extends Component {
    constructor(props) {
        super(props);
           this.state={
               data:[]
           }
    }

    componentDidMount() {
        this.getData()
    }

    getData=()=>{
      console.log(2222)
     let api='http://123.57.67.148:3000/mock/609/getData';
     axios.get(api).then(res=>{
       console.log(res.data)
       const result = res.data;
       // const result = JSON.parse(res.data);
       
         this.setState({
           data:result
         })
        
     }).catch(err=>{
       console.log(err)
     })
      
   }

    

    render() {
        const {data} = this.state
        return (
            <div className="div">
                <Row>
              <Col span={4}>
          <Input placeholder="团购编号" />
      </Col>  
      <Col span={4}>
      <Select defaultValue="状态请选择" onChange={handleChange}>
        <Option value="拼团中">拼团中</Option>
        <Option value="拼团成功">拼团成功</Option>
        <Option value="拼团失败（待退款）">拼团失败（待退款）</Option>
        <Option value="拼团失败（已退款）">拼团失败（已退款）</Option>
      </Select>
      </Col>
      </Row>
      <Table  columns={columns} dataSource={data}/>
            </div>
        );
    }
}

GroupPurchase.propTypes = {

};

export default GroupPurchase;